package jp.go.aist.six.vuln.core;

import java.util.ArrayList;
import java.util.List;
import jp.go.aist.six.vuln.core.repository.scap.nvd.NvdDataFeedInstaller;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;



/**
 */
@RunWith( Enclosed.class )
public class NvdAnalyzer
{

    ///////////////////////////////////////////////////////////////////////
    //  NVD Data Feed (1999-2012), as of 2013-02-26
    ///////////////////////////////////////////////////////////////////////

    private static final String  _DATA_DIR_ = "src/test/resources/nvd_data_feed_20130226";


    private static final String[]  _DATA_FILENAMES_ = new String[] {
        "nvdcve-2.0-2002.xml",
        "nvdcve-2.0-2003.xml",
        "nvdcve-2.0-2004.xml",
        "nvdcve-2.0-2005.xml",
        "nvdcve-2.0-2006.xml",
        "nvdcve-2.0-2007.xml",
        "nvdcve-2.0-2008.xml",
        "nvdcve-2.0-2009.xml",
        "nvdcve-2.0-2010.xml",
        "nvdcve-2.0-2011.xml",
        "nvdcve-2.0-2012.xml"
//        "nvdcve-2.0-2013.xml"
    };




    /**
     * Setup:
     */
    public static class Setup
    {

        public static String[] dataFilepathList()
        {
            List<String>  filepath_list = new ArrayList<String>();
            for (String  filename : _DATA_FILENAMES_) {
                filepath_list.add( _DATA_DIR_ + "/" + filename );
            }

            return filepath_list.toArray( new String[0] );
        }



        @Test
        public void installData()
        throws Exception
        {
            NvdDataFeedInstaller  installer = new NvdDataFeedInstaller();
            installer.execute( dataFilepathList() );
        }

    }
    //

}
